import java.util.concurrent.CountDownLatch;

public class Run implements Runnable{
    private double[][] A;
    private double[][] B;
    private int index;
    private int gap;
    private double[][] result;
    private CountDownLatch countDownLatch;

    public Run(double[][] a, double[][] b, int index, int gap, double[][] result, CountDownLatch countDownLatch) {
        A = a;
        B = b;
        this.index = index;
        this.gap = gap;
        this.result = result;
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        for(int i = index*gap;i < (index+1)*gap;i++){
            for(int j = 0;j < B[0].length;j++){
                for(int k = 0;k < B.length;k++){
                    result[i][j] += A[i][k]*B[k][j];
                }
            }
        }
        countDownLatch.countDown();
    }
}


